// import {
//     menuNav
// } from '@/api/menu'

//从服务端获取
const mock = [{
        "name": "•  工厂管理",
        "path": '/factoryManagement',
        "leaf": false,
        "children": [{
            "name": "•  工厂管理",
            "path": '/factoryManagement/factoryManagement',
            "leaf": true,
            "children": []
        }]
    },
    {
        "name": "•  系统管理",
        "path": '/system',
        "leaf": false,
        "children": [{
            "name": "•  账号管理",
            "path": "/system/accountManagement",
            "leaf": true,
        }]
    }
]

const state = {
    loading: false,
    menuNav: {
        data: []
    }
}

const actions = {
    ['getMenuNav']({
        commit,
        state
    }) {
        state.loading = true
        return new Promise(() => {
            // menuNav().then(response => {
            //     // console.log(mock);
            commit('setMenuNav', mock)
            state.loading = false
            //     resolve()
            // }).catch(error => {
            //     state.loading = false
            //     reject(error)
            // })
        })
    },
}

const mutations = {

    ['setMenuNav'](state, payload) {
        state.menuNav = {
            data: payload
        }
    }

}

const getters = {
    ['getMenuNav'](state) {
        return state.menuNav;
    },
    ['loading'](state) {
        return state.loading;
    },
}

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}